package com.kz.himalaya.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.kz.himalaya.bean.TabsData;

import java.util.List;

/**
 * Created by Administrator on 2017/1/23.
 */

public class TabAdapter extends FragmentPagerAdapter {

    private final List<TabsData.Tab> list;
    private final List<Fragment> fragments;

    public TabAdapter(FragmentManager fm, List<TabsData.Tab> list,List<Fragment> fragments) {
        super(fm);
        this.list = list;
        this.fragments = fragments;
    }

    @Override
    public Fragment getItem(int position) {
        return fragments.get(position);
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return list.get(position).getTitle();
    }
    public void addAll(List<TabsData.Tab> tab){
        list.addAll(tab);
        notifyDataSetChanged();
    }
}
